<%--
  Created by IntelliJ IDEA.
  User: 给
  Date: 2020/12/2
  Time: 19:43
  To change this template use File | Settings | File Templates.
--%>
<%@ page import="java.sql.DriverManager" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.Statement" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<jsp:useBean id="user" class="com.media.bean.UserBean"></jsp:useBean>

<jsp:setProperty name="user" property="*"></jsp:setProperty>

<%
    //加载数据库驱动
    Class.forName("com.mysql.jdbc.Driver");

    String url = "jdbc:mysql://localhost:3306/book";
    //建立数据库连接
    Connection connection = DriverManager.getConnection(url,"root","root");//alt+enter 自动引入类

    //创建Statement对象执行sql语句
    Statement stmt = connection.createStatement();

    String sql = "delete from user where id = 15";

    int count = stmt.executeUpdate(sql);

    if(count>0){
        out.print("执行成功");
    }else{
        out.print("执行失败");
    }

%>